package com.tianlu.store.enums;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

@AllArgsConstructor
@NoArgsConstructor
public enum OrderStatusEnum {
	/**
     * 	状态：1待发货，2待收货，3待评价，4已完成，5退款中，6已退款
	 */
	WAIT_SEND(1,"待发货"),
	WAIT_TAKE(2,"待收货"),
	WAIT_JUDGE(3,"待评价"),
	DONE(4,"已完成"),
	WAIT_REFUND(5,"退款中"),
	REFUNDED(6,"已退款");

	private final static Map<Integer, OrderStatusEnum> map = new HashMap<>();
	
	public Integer value;
	public String text;

	/**
	 * 根据code获取去枚举对象
	 * @param value 消息编码
	 * @return ResponseMessage
	 */
	public static String findByCode(Integer value) {
		if (map.size() == 0) {
			for (OrderStatusEnum status : values()) {
				map.put(status.value, status);
			}
		}
		OrderStatusEnum statusEnum = map.get(value);
		if (statusEnum != null) {
			return statusEnum.text;
		}
		return "";
	}

}
